package jjn.carl.string;

/**
 * @author Jiang Jining
 * @since 2023-07-05 23:31
 */
public class Offer5 {
    public String replaceSpace(String s) {
        StringBuilder sb = new StringBuilder();
        for (char c : s.toCharArray()) {
            if (c == ' ') {
                sb.append("%20");
            } else {
                sb.append(c);
            }
        }
        return sb.toString();
    }
    
    public static void main(String[] args) {
        String replacedSpace = new Offer5().replaceSpace("We are happy.");
        System.out.println("replacedSpace = " + replacedSpace);
    }
}
